package com.kaifa.org.tp05.example02.dao.impl;

import com.kaifa.org.tp05.example02.bean.Student;
import com.kaifa.org.tp05.example02.dao.StudentDao;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;

public class StudentDaoImpl implements StudentDao {
    private JdbcTemplate jdbcTemplate5;
    public void setJdbcTemplate5(JdbcTemplate jdbcTemplate5) {
        this.jdbcTemplate5 = jdbcTemplate5;
    }

    @Override
    public Student selectStudent(String userName, String pwd) {
        String sql="select * from t_student where stu_user_name=? and stu_user_pwd=?";
        RowMapper<Student> rowMapper = new BeanPropertyRowMapper<Student>(Student.class);
        Object[] args = new Object[]{userName,pwd};
        jdbcTemplate5.queryForObject(sql,rowMapper,args);
        Student student=jdbcTemplate5.queryForObject(sql,rowMapper,userName,pwd);
        return student;
    }
}
